import sys
from PyQt5.QtWidgets import QApplication, QGraphicsView, QGraphicsScene
from PyQt5.QtGui import QPixmap, QWheelEvent
from PyQt5.QtCore import Qt

class CustomGraphicsView(QGraphicsView):
    def __init__(self, scene):
        super().__init__(scene)
        # self.setRenderHint(QPixmap.Antialiasing)
        self.setDragMode(QGraphicsView.ScrollHandDrag)
        self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)

    def wheelEvent(self, event: QWheelEvent):
        factor = 1.2 if event.angleDelta().y() > 0 else 1 / 1.2
        self.scale(factor, factor)

def main():
    app = QApplication(sys.argv)
    scene = QGraphicsScene()
    
    view = CustomGraphicsView(scene)
    view.setSceneRect(0, 0, 800, 600)
    
    pixmap = QPixmap('images/demo.png')  # Replace with your image path
    scene.addPixmap(pixmap)
    
    view.show()
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()